package com.netty.app;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.netty.anno.PackageScan;
import com.netty.application.NettyApplication;
import com.netty.http.server.HtmlHttpServer;
import com.netty.http.server.JsonHttpServer;

@PackageScan("com.netty")
public class HttpApp {
	
	public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException{
		NettyApplication.run(HttpApp.class);
		ExecutorService pool = Executors.newFixedThreadPool(4);
		pool.submit(new Thread(){

			@Override
			public void run() {
				HtmlHttpServer htmlHttpServer = new HtmlHttpServer(8888);
				try {
					htmlHttpServer.start();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			
		});
		
		pool.submit(new Thread(){

			@Override
			public void run() {
				JsonHttpServer jsonHttpServer = new JsonHttpServer(8880);
				try {
					jsonHttpServer.start();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			
		});
		
//		HtmlHttpServer jsonHttpServer = new HtmlHttpServer(8888);
//		try {
//			jsonHttpServer.start();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
		
//		JsonHttpServer jsonHttpServer = new JsonHttpServer(8888);
//		try {
//			jsonHttpServer.start();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
	}
	
}
